import { RECORD_STATUS } from '@/enum/common';
import { GET, POST } from '@/libs';
import { UserInfo } from '@/store/modules/user.module';

export type MessageBoard = {
  id: number;

  userId: number;

  /**
   * 用户详情信息
   */
  userInfo: UserInfo;

  content: string;

  status: RECORD_STATUS;
};

export type MessageBoardForLoop = {
  id: number;
  content: string;
  nickname: string;
  avatarUrl: string;
};

export const getMessageBoardList = () => {
  return GET<MessageBoard[]>({
    url: '/message-board/getMessageBoardList'
  });
};

type addMessageResponse = {
  id: number;
  content: string;
};

export const addMessage = (content: string) => {
  return POST<addMessageResponse>({
    url: '/message-board/addMessage',
    data: {
      content
    }
  });
};
